package com.spark.check

import android.app.Activity
import android.content.Intent
import android.os.Bundle
import com.spark.common.BaseActivity
import java.io.Serializable

class ChkActivity : BaseActivity() {
    private var progress: ChkProgress = ChkProgress.TO_AUDIT
    private var id: String = ""

    companion object {
        fun actionStart(host: Activity, progress: ChkProgress, id: String) {
            val intent = Intent(host, ChkActivity::class.java)
            intent.putExtra("progress", progress)
            intent.putExtra("id", id)
            host.startActivity(intent)
        }
    }

    override fun contentResId(): Int {
        return R.layout.act_chk
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        intent?.apply {
            progress = getSerializableExtra("progress")?.let { it as ChkProgress } ?: ChkProgress.TO_AUDIT
            id = getStringExtra("id")
        }
        loadRootFragment(R.id.fl_content, when (progress) {
            ChkProgress.TO_AUDIT -> ToAuditFragment.newInstance()
            ChkProgress.TO_CHK -> ToCheckFragment.newInstance(id)
            ChkProgress.TO_CHK_APPR -> ToChkApproveFragment.newInstance()
            ChkProgress.TO_ACCEPT -> ToAcceptFragment.newInstance(id)
        })
    }
}

enum class ChkProgress : Serializable {
    //待接受
    TO_ACCEPT,
    // 待审核
    TO_AUDIT,
    // 待检查
    TO_CHK,
    // 待审阅
    TO_CHK_APPR,
}